<div class="form-group">
    <label class="col-lg control-label">排序</label>
    <div class="col-sm-9 col-xs-12">
        <input type='number' class='form-control' name='displayorder' value="{$item['displayorder']}"/>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label must">商品类型</label>
    <div class="col-sm-9 col-xs-12">
            <label class="radio-inline"><input type="radio" name='goodstype' value="0" {if empty($item['goodstype'])}checked{/if} {if !empty($item)} disabled{/if} />商品</label>
            <label class="radio-inline" style="display: none;"><input type="radio" name='goodstype' value="1" {if $item['goodstype']==1}checked{/if} {if !empty($item)} disabled{/if} />优惠券</label>
            <label class="radio-inline" style="display: none;"><input type="radio" name='goodstype' value="2" {if $item['goodstype']==2}checked{/if} {if !empty($item)} disabled{/if} />余额</label>
            <label class="radio-inline" style="display: none;"><input type="radio" name='goodstype' value="3" {if $item['goodstype']==3}checked{/if} {if !empty($item)} disabled{/if} />虚拟物品</label>
            <label class="radio-inline" style="display: none;"><input type="radio" name='goodstype' value="4" {if $item['goodstype']==4}checked{/if} {if !empty($item)} disabled{/if} />红包</label>
            <div class='help-block cgt cgt-0' {if !empty($item['goodstype'])}style="display:none"{/if}>保存后商品类型不可更改</div>
            <div class='help-block cgt cgt-1' {if $item['goodstype']!=1}style="display:none"{/if}>设置为优惠券类型，则无需进行领取，兑换或抽中直接发送到优惠券账户(保存后商品类型不可更改)</div>
            <div class='help-block cgt cgt-2' {if $item['goodstype']!=2}style="display:none"{/if}>设置为余额类型，则无需进行领取，兑换或抽中直接发送到用户账户(保存后商品类型不可更改)</div>
            <div class='help-block cgt cgt-3' {if $item['goodstype']!=3}style="display:none"{/if}>设置为红包类型，则无需进行领取，兑换或抽中直接发送微信红包(保存后商品类型不可更改)</div>
    </div>
</div>

<div class="form-group cgt cgt-0" {if $item['goodstype']!=0}style="display:none"{/if}>
    <label class="col-lg control-label">设置商品</label>
    <div class="col-sm-9 col-xs-12">
        {:tpl_selector('goodsid', array('required'=>false, 'preview'=>false,'url'=>url('admin/creditshop/goodsquery'), 'items'=>$goods, 'readonly'=>true, 'buttontext'=>'选择商品', 'placeholder'=>'请选择商品','callback'=>'select_goods'))}
        <div class="help-block">提示：您可选择商城商品或自行设置商品信息(此项非必选)</div>
    </div>
</div>
<div class="form-group cgt cgt-1" {if $item['goodstype']!=1}style="display:none"{/if}>
    <label class="col-lg control-label">选择优惠券</label>
    <div class="col-sm-9 col-xs-12">
        {:tpl_selector('couponid',array('required'=>false, 'preview'=>true,'url'=>url('admin/sale/couponquery'),'text'=>'couponname','items'=>$coupon,'readonly'=>true,'buttontext'=>'选择优惠券','placeholder'=>'请选择优惠券','callback'=>'select_coupon'))}
    </div>
</div>

<div class="form-group cgt cgt-2" {if $item['goodstype']!=2}style="display:none"{/if}>
    <label class="col-lg control-label">设置余额</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixsingle-input-group">
            <span class="input-group-addon">余额</span>
            <input type="number" class="form-control" name="grant1" value="{$item['grant1']}">
            <span class="input-group-addon">元</span>
        </div>
    </div>
</div>
<div class="form-group cgt cgt-3" {if $item['goodstype']!=3 || $item['packetmoney']<=0}style="display:none"{/if}>
    <label class="col-lg control-label">红包总发放金额</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixmore-input-group" >
            <span class="input-group-addon">总额</span>
            <input type="number" class="form-control" name="packetmoney" value="{$item['packetmoney']}" {if !empty($item)} disabled{/if}>
            <span class="input-group-addon">元 剩余</span>
            <input type="number" class="form-control" name="surplusmoney" disabled value="{$item['surplusmoney']}">
            <span class="input-group-addon">元</span>
        </div>
    </div>
</div>
<div class="form-group cgt cgt-3" {if $item['goodstype']!=3 || $item['packetmoney']<=0}style="display:none"{/if}>
    <label class="col-lg control-label">红包兑换限制</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixmore-input-group">
            <span class="input-group-addon">剩余金额小于</span>
            <input type="number" class="form-control" name="packetlimit" value="{$item['packetlimit']}">
            <span class="input-group-addon">元，停止兑换</span>
        </div>
        <span class='help-block'>剩余金额小于X时，停止兑换。如果为空，剩余金额为0时停止兑换。</span>
    </div>
</div>
<div class="form-group cgt cgt-3" {if $item['goodstype']!=3 || !$item['packettotal']>0}style="display:none"{/if}>
    <label class="col-lg control-label">红包个数</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixmore-input-group">
            <span class="input-group-addon">红包</span>
            <input type="text" class="form-control" name="packettotal" {if !empty($item)} disabled{/if} value="{$item['packettotal']}">
            <span class="input-group-addon">个 剩余</span>
            <input type="text" class="form-control" name="packetsurplus" disabled value="{$item['packetsurplus']}">
            <span class="input-group-addon">个</span>
        </div>
    </div>
</div>
<div class="form-group cgt cgt-3" {if $item['goodstype']!=3}style="display:none"{/if}>
    <label class="col-lg control-label">红包类型</label>
    <div class="col-sm-9 col-xs-12" style='padding-left:0'>
        <div class="input-group fixmore-input-group">
            <span class='input-group-addon' style='border:none'>
                <label class="radio-inline" style='margin-top:-7px;' >
                    <input type="radio" name="packettype" value="1" {if $item['packettype'] == 1}checked="true"{/if} {if !empty($item)} disabled{/if} /> 随机金额
                </label>
            </span>
            <span class="input-group-addon">每个红包最低</span>
            <input type="number" class="form-control" name="minpacketmoney" {if !empty($item)} disabled{/if} value="{$item['minpacketmoney']}">
            <span class="input-group-addon">元</span>
        </div>
    </div>
</div>
<div class="form-group cgt cgt-3" {if $item['goodstype']!=3}style="display:none"{/if}>
    <label class="col-lg control-label"></label>
    <div class="col-sm-9 col-xs-12" style='padding-left:0'>
        <div class="input-group fixmore-input-group">
            <span class='input-group-addon' style='border:none'>
                <label class="radio-inline"  style='margin-top:-7px;' >
                    <input type="radio"name="packettype" value="0" {if !empty($item)} disabled{/if} {if empty($item['packettype'])}checked="true"{/if}  /> 固定金额
                </label>
            </span>
            <input type="text" name="grant2" id="grant2" class="form-control" {if !empty($item)} disabled{/if} value="{$item['grant2']}" />
            <span class="input-group-addon">元</span>
        </div>
    </div>
</div>


<div class="form-group">
    <label class="col-lg control-label must">商品标题</label>
    <div class="col-sm-9 col-xs-12">
        <input type='text' class='form-control' id="goodsname" name='title' value="{$item['title']}" id="title" data-rule-required='true' data-msg-required='请设置标题'/>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label must">商品分类</label>
    <div class="col-sm-9 col-xs-12">
        <select class='form-control' name='cate' data-rule-required='true' data-msg-required='请选择分类'>
            <option value=''>请选择商品分类</option>
            {foreach name='category' item='cate'}
                <option value='{$cate['id']}' {if $item['cate']==$cate['id']}selected{/if}>{$cate['name']}</option>
            {/foreach}
        </select>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label">商品图片</label>
    <div class="col-sm-9 col-xs-12 thumb-container gimgs">
        {:tpl_form_field_image2('thumb',$item['thumb'])}
    </div>
</div>
<div class="form-group" {if $item['goodstype']!=0}style="display:none"{/if}>
    <label class="col-lg control-label">商品原价</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixsingle-input-group">
            <input type="text" name="price" id="price" class="form-control" value="{$item['price']}" />
            <!--<span class="input-group-addon">原价</span>
            <input type="text" name="productprice" id="productprice" class="form-control" value="{$item['productprice']}" />-->
            <span class="input-group-addon">元</span>
        </div>
        <span class='help-block'></span>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label">兑换限制</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixmore-input-group">
            <span class="input-group-addon">每人每天</span>
            <input type='text' class='form-control' value="{$item['chanceday']}" name='chanceday' />
            <span class="input-group-addon" style="border-right: 0;">每人共</span>
            <input type='text' class='form-control' value="{$item['chance']}" name='chance' />
            <span class="input-group-addon">次，每天提供</span>
            <input type='text' class='form-control' value="{$item['totalday']}" name="totalday" />
            <span class="input-group-addon">份</span>
        </div>
        <span class="help-block">空为不限制</span>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label must">活动消耗</label>
    <div class="col-sm-9 col-xs-12">
        <div class="input-group fixmore-input-group">
            <span class="input-group-addon">消耗</span>
            <input type='text' class='form-control' value="{$item['credit']}" name='credit'/>
            <span class="input-group-addon">积分 + 金额</span>
            <input type='text' class='form-control' value="{$item['money']}" name='money'/>
            <span class="input-group-addon">元&nbsp;&nbsp;
                <label class="checkbox-inline" style='margin-top:-8px;display:none;'>
                    <input type="checkbox" name='usecredit2' value="1" {if $item['usecredit2']==1}checked{/if} /> 优先使用余额支付
                </label>
            </span>
        </div>
        <span class="help-block">可任意组合，可以单独积分兑换，或者积分+现金形式兑换(积分必须大于0)</span>
    </div>
</div>
<div class="form-group dispatch_info" {if $item['goodstype']!=0}style="display:none"{/if}>
    <label class="col-lg control-label">运费设置</label>
    <div class="col-sm-6 col-xs-6" style='padding-left:0'>
        <div class="input-group">
            <span class='input-group-addon' style='border:none'><label class="radio-inline" style='margin-top:-7px;' ><input type="radio" name="dispatchtype" value="1" {if $item['dispatchtype'] == 1}checked="true"{/if} /> 运费模板</label></span>
            <select class="form-control tpl-category-parent select2" id="dispatchid" name="dispatchid">
                <option value="0">默认模板</option>
                {foreach name='dispatch_data' item='dispatch_item'}
                <option value="{$dispatch_item['id']}" {if $item['dispatchid'] == $dispatch_item['id']}selected="true"{/if}>{$dispatch_item['dispatchname']}</option>
                {/foreach}
            </select>
        </div>
    </div>
    </div>
    <div class="form-group dispatch_info" {if $item['goodstype']!=0}style="display:none"{/if}>
    <label class="col-lg control-label"></label>
    <div class="col-sm-6 col-xs-6" style='padding-left:0'>
        <div class="input-group fixsingle-input-group">
            <span class='input-group-addon' style='border:none'><label class="radio-inline"  style='margin-top:-7px;' ><input type="radio"name="dispatchtype" value="0" {if empty($item['dispatchtype'])}checked="true"{/if}  /> 统一邮费</label></span>
            <input type="text" name="dispatch" id="dispatch" class="form-control" value="{$item['dispatch']}" />
            <span class="input-group-addon">元</span>
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label">商品属性</label>
    <div class="col-sm-9 col-xs-12" >
        <!--<label for="istop" class="checkbox-inline">
            <input type="checkbox" name="istop" value="1" id="istop" {if $item['istop'] == 1}checked="true"{/if} /> 置顶
        </label>-->
        <label for="isrecommand" class="checkbox-inline">
            <input type="checkbox" name="isrecommand" value="1" id="isrecommand" {if $item['isrecommand'] == 1}checked="true"{/if} /> 推荐
        </label>
        <label for="istime" class="checkbox-inline">
            <input type="checkbox" name="istime" value="1" id="istime" {if $item['istime'] == 1}checked="true"{/if} /> 限时购买
        </label>
    </div>
</div>
<div class="form-group" id="creditshoptime" {if $item['istime'] != 1}style="display:none;"{/if}>
    <label class="col-lg control-label">限时购买</label>
    <div class="col-sm-4 col-xs-6">
        {:tpl_form_field_date('timestart', !empty($item['timestart']) ? date('Y-m-d H:i',$item['timestart']) : date('Y-m-d H:i'), 1)}
    </div>
    <div class="col-sm-4 col-xs-6">
        {:tpl_form_field_date('timeend', !empty($item['timeend']) ? date('Y-m-d H:i',$item['timeend']) : date('Y-m-d H:i'), 1)}
    </div>
</div>
<div class="form-group">
    <label class="col-lg control-label">活动状态</label>
    <div class="col-sm-9 col-xs-12">
        <label class="radio-inline"><input type="radio" name='status' value="1" {if $item['status']==1}checked{/if} /> 开启</label>
        <label class="radio-inline"><input type="radio" name='status' value="0" {if empty($item['status'])}checked{/if} /> 暂停</label>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $("#istime").on("click",function(){
            if($(this).prop("checked")){
                $("#creditshoptime").show();
            }else{
                $("#creditshoptime").hide();
            }
        })
    })
</script>